package net.siufung.core.model.enums;

import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;

import java.util.List;

/**
 * @author 陈建峰
 * @since 2021/11/29 5:43 下午
 */
@ToString
public enum InitializeEnum {

    /**
     * 是
     */
    IS(true,"是"),
    /**
     * 否
     */
    NOT(false,"否");

    @Getter
    @Setter
    private Boolean value;

    @Getter
    @Setter
    private String desc;

    InitializeEnum(Boolean value, String desc ) {
        this.value = value;
        this.desc = desc;
    }

    public static InitializeEnum get(Boolean value) {
        InitializeEnum[] enums = values();
        for (InitializeEnum enumOf : enums) {
            if (enumOf.getValue().equals(value)) {
                return enumOf;
            }
        }
        return null;
    }

    public static String getDesc(Boolean value) {
        InitializeEnum[] enums = values();
        for (InitializeEnum enumOf : enums) {
            if (enumOf.getValue().equals(value)) {
                return enumOf.getDesc();
            }
        }
        return null;
    }

    public static List<EnumsVo> getList(){
        List<EnumsVo> enumsVOList = Lists.newLinkedList();
        EnumsVo enumsVO = null;
        for (InitializeEnum enumOf: values()) {
            enumsVO = new EnumsVo();
            enumsVO.setValue(enumOf.getValue());
            enumsVO.setDesc(enumOf.getDesc());
            enumsVOList.add(enumsVO);
        }
        return enumsVOList;
    }
}
